package com.jas.common;

import java.util.Calendar;


public class DeadlineEvent extends Event{
	
	@SuppressWarnings("unused")
	private final String CLASS_NAME = this.getClass().getSimpleName(); // Used by the gson deserializer
	
	protected Calendar eventEndDateTime;

	//@author a0118677r
	public DeadlineEvent(String eventDescription, Calendar eventDeadline){
		super();
		this.setEventDescription(eventDescription);
		this.setEventEndDateTime(eventDeadline);
	}
	
	//@author a0118677r
	public DeadlineEvent(String eventId, String eventDescription, Calendar eventDeadline){
		super(eventId);
		this.setEventDescription(eventDescription);
		this.setEventEndDateTime(eventDeadline);
	}
	
	//@author a0118677r
	@Override
	public Event copy(){
		Event copy = new DeadlineEvent(this.getEventId(), this.getEventDescription(), this.getEventEndDateTime());
		copy.setCompleted(this.isCompleted());
		return copy;
	}
	
	//@author a0118677r
	public Event convertToTimedEvent(Calendar startDateTime) throws EventDateException {
		Event timedEvent = new TimedEvent(this.getEventId(), this.getEventDescription(), startDateTime, this.getEventEndDateTime());
		return timedEvent;
	}

	//@author a0118677r
	public Calendar getEventEndDateTime() {
		return eventEndDateTime;
	}

	//@author a0118677r
	public void setEventEndDateTime(Calendar eventEndDateTime) {
		this.eventEndDateTime = eventEndDateTime;
	}

	//@author a0118677r
	@SuppressWarnings("rawtypes")
	@Override
	public Class getSubClass() {
		return this.getClass();
	}

	//@author a0118677r
	@Override
	public String toString() {
		String completionStatus="";
		if(isCompleted()){
			completionStatus=Language.getString("KEYWORD_YES");
		}
		else{
			completionStatus=Language.getString("KEYWORD_NO");
		}
		String endDateTime = Utilities.calendarToString(eventEndDateTime,Language.getString("DATE_FORMAT"));

		return String.format(Language.getString("DISPLAY_EVENT"), getEventDescription(), "", endDateTime, completionStatus, getEventId());
	}

}
